package net.lzzy.demomybatis.mapper;

import net.lzzy.demomybatis.entity.Comment;
import org.apache.ibatis.annotations.*;

import javax.swing.plaf.PanelUI;
import java.util.List;

@Mapper
public interface CommentMapper {
    @Select("SELECT * FROM t_comment WHERE id=#{id}")
    public Comment findById(Integer id);

    @Select("SELECT * FROM t_comment")
    public List<Comment> getAllComments();

    @Insert("INSERT INTO t_comment(content,author,a_id)" +
    "values (#{content},#{author},#{aId})")
    public int addComment(Comment comment);

    @Update("UPDATE t_comment SET content=#{content} WHERE id=#{id}")
    public int updateCommentById(Comment comment);

    @Delete("DELETE FROM t_comment WHERE id=#{id}")
    public int deleteCommentById(int id);
}
